﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GatewayInspect.Common;
using System.Data.OracleClient;

namespace GatewayInspect.Modules
{
    public partial class FeiKModule : BaseModule
    {
        public FeiKModule()
        {
            InitializeComponent();
        }

        protected override void OnInitialize()
        {
            base.OnInitialize();

            foreach (ToolStripItem item in this.tsMain.Items)
            {
                if (item != tsBtnClose)
                {
                    item.Visible = false;
                }
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string strTruckNo = this.tbxTruckNo.Text.Trim();
            if (string.IsNullOrEmpty(strTruckNo))
            {
                MessageBox.Show("车牌号不能为空！");
                return;
            }
            DataTable dtRFID = DataAccess.ExecuteDataTable("select CARDID from RFID_READ where CARDSTATE = '0' and CHEHAO = '" + strTruckNo + "'");
            if (dtRFID == null || dtRFID.Rows.Count <= 0)
            {
                MessageBox.Show("该车未发卡！");
                return;
            }
            DataAccess.ExecuteNonQuery("update RFID_READ set CARDSTATE='1' where CARDSTATE = '0' and CHEHAO = '" + strTruckNo + "'");
            MessageBox.Show("废卡成功！");
        }

        private void btnQuery_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(tbxTruckNo.Text))
            {
                string strSql = "select CARDID,CHEHAO,SENDCARDTIME,SENDCARDMAN,HD_WEIGHT from RFID_READ where CARDSTATE = '0' and CHEHAO = '" + tbxTruckNo.Text.Trim() + "'";
                cdgvFeiK.DataSource = DataAccess.ExecuteDataTable(strSql);
            }
            else
            {
                MessageBox.Show("车牌号不能为空！");
            }
        }
    }
}
